﻿using System.Configuration;
using T.ServiceComponent.Cluster.Client;

namespace T.FAS.Runtime.DataModel.Plugin
{
    public class CommonUtil
    {
        public static string GetCurrentDomain(bool isInternalSG = true)
        {
            var bigDataPublishDomain = ConfigurationManager.AppSettings["DcpServiceRoot"];
            if (!string.IsNullOrEmpty(bigDataPublishDomain)) return bigDataPublishDomain;
            var dataCenterId = AppClusterLocalClient.GetInstance().GetCurrentDataCenterId();
            return AppClusterLocalClient.GetInstance().GetDataCenterDomain(dataCenterId, isInternalSG);
        }

        public static string GetCurrentBDPPublishDomain()
        {
            var bigDataPublishDomain = ConfigurationManager.AppSettings["DcpServiceRoot"];
            if (!string.IsNullOrEmpty(bigDataPublishDomain)) return bigDataPublishDomain;
            var dataCenterId = AppClusterLocalClient.GetInstance().GetCurrentDataCenterId();
            return AppClusterLocalClient.GetInstance().GetDataCenterDomain(dataCenterId, false);
        }
    }
}
